package com.dios.mirage.content;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.VerticalFieldManager;

import com.dios.mirage.component.HFocusableManager;
import com.dios.mirage.component.fields.FocusableField;
import com.dios.mirage.component.view.View;
import com.dios.mirage.navigation.Navigation;

public class ModelContent extends Content {

	private HorizontalFieldManager modelManager;
	private VerticalFieldManager specManager;
	private HorizontalFieldManager dimensionManager;
	private HorizontalFieldManager guarantee;

	public void createGUI() {
		modelManager = new HFocusableManager();
		specManager = new VerticalFieldManager();
		dimensionManager = new HFocusableManager();
		guarantee = new HorizontalFieldManager();
		int imageWidht = Display.getWidth();
		
		LabelField titleLabel = new LabelField("MODEL & SPECIFICATION") {
			public void paint(Graphics g) {
				g.setColor(Color.RED);
				super.paint(g);
			}
		};
		titleLabel.setFont(Navigation.loadCustomFonts(getClass().getResourceAsStream(Navigation.fontPath), Font.BOLD, 30));
		
		ImgField[] modelFields = new ImgField[] {
				new ImgField(View.createImage("img/model/exceed.jpg",imageWidht,250).getBitmap()),
				new ImgField(View.createImage("img/model/gls.jpg",imageWidht,250).getBitmap()),
				new ImgField(View.createImage("img/model/glx.jpg",imageWidht,250).getBitmap())
		};
		modelManager.addAll(modelFields);
		
		BitmapField[] specFields = new BitmapField[]{
				new BitmapField(View.createImage("img/model/specification-1.png",imageWidht,0).getBitmap()),
				new BitmapField(View.createImage("img/model/specification-2.png",imageWidht,0).getBitmap())
		};
		specManager.addAll(specFields);
		
		ImgField[] dimensionFields = new ImgField[]{
				new ImgField(View.createImage("img/model/dimension-1.png",imageWidht,250).getBitmap()),
				new ImgField(View.createImage("img/model/dimension-2.png",imageWidht,250).getBitmap()),
				new ImgField(View.createImage("img/model/dimension-3.png",imageWidht,250).getBitmap())
		};
		dimensionManager.addAll(dimensionFields);
		
		BitmapField garansiField = new BitmapField(View.createImage("img/model/garansi.jpg", imageWidht/2, imageWidht/4).getBitmap());
		BitmapField bengkelField = new BitmapField(View.createImage("img/model/bengkel.jpg", imageWidht/2, imageWidht/4).getBitmap());
		guarantee.add(garansiField);
		guarantee.add(bengkelField);

		add(titleLabel);
		add(modelManager);
		add(specManager);
		add(dimensionManager);
		add(guarantee);
	}
	
	private class ImgField extends FocusableField{

		public ImgField(Bitmap bitmap) {
			super(bitmap, Field.FOCUSABLE);
		}
		
	}
}
